package com.yict.csms.resourceplan.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.yict.common.service.impl.BaseServiceImpl;
import com.yict.csms.resourceplan.dao.ICarStableNeedhourDao;
import com.yict.csms.resourceplan.entity.CarStableNeedhour;
import com.yict.csms.resourceplan.service.ICarStableNeedhourService;

@Service("carStableNeedhourService")
public class CarStableNeedhourServiceImpl extends BaseServiceImpl<CarStableNeedhour, Long, ICarStableNeedhourDao> implements ICarStableNeedhourService {

	@Resource(name = "carStableNeedhourDao")
	public void setBaseDao(ICarStableNeedhourDao baseDao) {
		super.setBaseDao(baseDao);
	}

	@Override
	public List<CarStableNeedhour> findByDataDictId(List<String> dictIds) {
		List<CarStableNeedhour> list = new ArrayList<CarStableNeedhour>();
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuilder hql = new StringBuilder("from CarStableNeedhour t where 1=1 and t.datadictid in (:dictIds)");
		map.put("dictIds", dictIds);
		list = this.getBaseDao().list(hql.toString(), map, 0, 0);
		return list;
	}

	@Override
	public List<CarStableNeedhour> findByTimeId(Long timeid) {
		List<CarStableNeedhour> list = new ArrayList<CarStableNeedhour>();
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuilder hql = new StringBuilder("from CarStableNeedhour t where 1=1");
		if(timeid != null) {
			hql.append(" and t.carTime.timeid = :timeid");
			map.put("timeid", timeid);
		}
		list = this.getBaseDao().list(hql.toString(), map, 0, 0);
		return list;
	}
}
